// mypage/teamMember/teamMember.js
var app=getApp();
var util=require("../../utils/util")
var my=require("../../api/my")


Page({

  /*页面的初始数据*/
  data: {
    teamList: [],
    currentPage: 1,
    pageSize: 20,
    total: 0
  },
  /*生命周期函数--监听页面加载*/
  onLoad: function (options) {
    var that=this;
    that.get_my_team()
  },
  // 触底
  onReachBottom:function(){
    var that=this,total=that.data.total,teamList=that.data.teamList;
    if(teamList.length<total){
      that.setData({currentPage:that.data.currentPage+1})
      that.get_my_team()
    }else{
      util.page_show_toast('没有更多了',1500)
    }
  },
  get_my_team:function(){
    wx.showLoading()
    var that=this,token=wx.getStorageSync("token"),currentPage=that.data.currentPage,pageSize=that.data.pageSize,teamList=that.data.teamList;
    var params={
      currentPage: currentPage,
      pageSize: pageSize
    }
    my.get_team(params,token).then(res=>{
      wx.hideLoading()
      var {total,records}=res.data.data
      teamList.push(...records)
      that.setData({total:total,teamList:teamList})
    })
  },
})